<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>prompt()函数</title>
</head>
<body>
    <script>
        let row=prompt('请输入所需图形行数');
        triangle(row);
        parallelogram(row);
        function triangle(a){
            let str="";
            for(let i=a;i>=0;i--){
                for(let j=0;j<=i;j++)
                {
                    str+=" ";
                }
                for(let n=0;n<=2*a-2*i;n++)
                {
                    str+="*";
                }
                str+="\n";
            }
            console.info(str);
        };
        function parallelogram(a){
            let str="";
            for(let i=a;i>=0;i--){
                for(let j=0;j<=i;j++)
                {
                    str+=" ";
                }
                for(let m=1;m<=a;m++)
                {
                    str+="*";
                }
                str+="\n";
            }
            console.info(str);
        };
    </script>
</body>
</html>